From: Philip Chimento Date: Wed, 23 Oct 2019 00:48:00 +0000 (-0700) Subject: dnd: Skip drag target when its acceptDrop() throws an exception X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~781^2^2~500 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=055c007ac26b6475cc2821dbfc2e760ec4f3a9a6;p=gnome-shell.git dnd: Skip drag target when its acceptDrop() throws an exception In the case of bugs in a drag target's acceptDrop() function, it may throw an exception. In the previous code, this would break out of the loop entirely and never cancel the drag, so the mouse button release event would be ignored and you would have to press Esc to get out of the drag. In this change, if acceptDrop() throws an exception, we log it and move on to the next parent target instead. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/777 --- diff --git a/js/ui/dnd.js b/js/ui/dnd.js index 786d65419..7d3929d6e 100644 --- a/js/ui/dnd.js +++ b/js/ui/dnd.js @@ -573,11 +573,15 @@ var _Draggable = class _Draggable { while (target) { if (target._delegate && target._delegate.acceptDrop) { let [r_, targX, targY] = target.transform_stage_point(dropX, dropY); - if (target._delegate.acceptDrop(this.actor._delegate, - this._dragActor, - targX, - targY, - event.get_time())) { + let accepted = false; + try { + accepted = target._delegate.acceptDrop(this.actor._delegate, + this._dragActor, targX, targY, event.get_time()); + } catch (e) { + // On error, skip this target + logError(e, "Skipping drag target"); + } + if (accepted) { // If it accepted the drop without taking the actor, // handle it ourselves. if (this._dragActor && this._dragActor.get_parent() == Main.uiGroup) {